#!/bin/bash
if [ -z "${1}" ]; then
        echo "ERROR! param mysqlrootpasswd is required!"
        exit 0
fi
time=$(date +"%Y%m%d%H%M%S")

databases=$(mysql -uroot -p${1} -e "show databases;")
#echo $databases
for database in $databases; do
#	echo $database
	if [ $database = 'Database' ] || [ $database = 'information_schema' ] || [ $database = 'performance_schema' ] || [ $database = 'mysql' ]
		then
		continue
	fi
	mysqldump -uroot -p${1} $database > /var/backup/database/$time-$database.sql
done
echo SUCCESS
